package com.hspedu.collection_;

import java.util.*;
import java.util.concurrent.Callable;

@SuppressWarnings({"all"})
public class CollectionsTool {
    public static void main(String[] args) {
        ArrayList arrayList = new ArrayList();
        List list = arrayList;
        list.add("tom");
        list.add("tom");

        list.add("tom");
        list.add("smith");
        list.add("king");
        list.add("milan");

//        Collections.reverse(list);
//        System.out.println(list);
//        Collections.shuffle(list);
//        Collections.sort(list);
//        Collections.sort(list, new Comparator() {
//            @Override
//            public int compare(Object o1, Object o2) {
//                return ((String) o1).length() - ((String) o2).length();
//            }
//        });
//        System.out.println(list);
//
//        Collections.swap(list,0,1);
//        System.out.println(Collections.max(list));
//        Object obj = Collections.max(list, new Comparator() {
//            @Override
//            public int compare(Object o1, Object o2) {
//                return ((String) o1).length() - ((String) o2).length();
//            }
//        });
//        System.out.println(obj);
//        System.out.println(Collections.frequency(list,"tom"));
//        ArrayList arrayList1 = new ArrayList(20);
//        Collections.copy(arrayList1,arrayList);
//        System.out.println();
        Collections.replaceAll(list,"tom","roen");
        System.out.println(list);
    }
}
